home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_optional.h.z / apr_optional.h
C/C++ Source or Header  |  2002-07-08  |  5KB  |  131 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_OPTIONAL_H
  56. #define APR_OPTIONAL_H
  57.  
  58. #include "apu.h"
  59. /** 
  60.  * @file apr_optional.h
  61.  * @brief APR-UTIL registration of functions exported by modules
  62.  */
  63. #ifdef __cplusplus
  64. extern "C" {
  65. #endif
  66.  
  67. /** 
  68.  * @defgroup APR_Util_Opt Optional Functions
  69.  * @ingroup APR_Util
  70.  *
  71.  * Typesafe registration and retrieval of functions that may not be present
  72.  * (i.e. functions exported by optional modules)
  73.  * @{
  74.  */
  75.  
  76. /**
  77.  * The type of an optional function.
  78.  * @param name The name of the function
  79.  */
  80. #define APR_OPTIONAL_FN_TYPE(name) apr_OFN_##name##_t
  81.  
  82. /**
  83.  * Declare an optional function.
  84.  * @param ret The return type of the function
  85.  * @param name The name of the function
  86.  * @param args The function arguments (including brackets)
  87.  */
  88. #define APR_DECLARE_OPTIONAL_FN(ret,name,args) \
  89. typedef ret (APR_OPTIONAL_FN_TYPE(name)) args
  90.  
  91. /**
  92.  * XXX: This doesn't belong here, then!
  93.  * Private function! DO NOT USE! 
  94.  * @internal
  95.  */
  96.  
  97. typedef void (apr_opt_fn_t)(void);
  98. /** @internal */
  99. APU_DECLARE_NONSTD(void) apr_register_optional_fn(const char *szName, 
  100.                                                   apr_opt_fn_t *pfn);
  101.     
  102.  
  103. /**
  104.  * Register an optional function. This can be later retrieved, type-safely, by
  105.  * name. Like all global functions, the name must be unique. Note that,
  106.  * confusingly but correctly, the function itself can be static!
  107.  * @param name The name of the function
  108.  */
  109. #define APR_REGISTER_OPTIONAL_FN(name) \
  110.     (((void (*)(const char *, APR_OPTIONAL_FN_TYPE(name) *)) \
  111.                &apr_register_optional_fn)(#name,name))
  112.  
  113. /** @internal
  114.  * Private function! DO NOT USE! 
  115.  */
  116. APU_DECLARE(apr_opt_fn_t *) apr_retrieve_optional_fn(const char *szName);
  117.  
  118. /**
  119.  * Retrieve an optional function. Returns NULL if the function is not present.
  120.  * @param name The name of the function
  121.  */
  122. #define APR_RETRIEVE_OPTIONAL_FN(name) \
  123.     (APR_OPTIONAL_FN_TYPE(name) *)apr_retrieve_optional_fn(#name)
  124.  
  125. /** @} */
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129.  
  130. #endif /* APR_OPTIONAL_H */
  131.